package com.meepo.basic

import android.app.Activity
import android.content.Context
import android.util.Log
import com.meepo.basic.auth.LoginActivity
import com.meepo.basic.auth.Store
import com.meepo.basic.schema.Session
import com.meepo.basic.schema.user.User
import com.meepo.basic.umeng.UMengManager
import com.meepo.basic.usersettings.UserSettingsStore
import com.meepo.sdk.utils.ActivityHelper
import com.meepo.sdk.utils.Utils
import com.umeng.analytics.MobclickAgent


/**
 * @author
 *
 * @date  2020/11/8 12:07 AM
 * @version 1.0
 */
object AppCoreModule {

    fun getSession(): Session {
        return State.getSession()
    }

    fun logout() {

        MobclickAgent.onProfileSignOff()

        Store.Func.clearUserSummary()
    }

    fun login(activity: Activity) {
//        LoginManager.start(activity)

        ActivityHelper.launch(activity, LoginActivity::class.java)
    }

    fun isLogined(): Boolean {
        return getUserSummary() != null
    }

    fun getUserSummary(): User? {
        return Store.Func.getUserSummary()
    }


    fun init(context: Context, source: String) {

        UMengManager.init(Utils.getApp(), source)

        UserSettingsStore.Func.initNighMode()
    }

    fun initSettings(callback: () -> Unit) {
        State.initSettings(callback)
    }
}
